#include "../audio/sound_manager.h"

namespace SMC
{
cSound::cSound(void)
{
	m_chunk = NULL;
}

cSound::~cSound(void)
{
	Free();
}

bool cSound::Load(const std::string& filename)
{
	Free();
	
	m_chunk = Mix_LoadWAV(filename.c_str());
	
	if (m_chunk)
	{
		m_filename = filename;
		return 1;
	}
	
	return 0;
}

void cSound::Free(void)
{
	if (m_chunk)
	{
		Mix_FreeChunk(m_chunk);
		m_chunk = NULL;
	}
	
	m_filename.clear();
}

cSound_Manager::cSound_Manager(void)
: cObject_Manager<cSound>()
{
	m_load_count = 0;
}

cSound_Manager::~cSound_Manager(void)
{
	cSound_Manager::Delete_All();
}

cSound* cSound_Manager::Get_Pointer(const std::string& path) const
{
	for (SoundList::const_iterator itr = objects.begin(); itr != objects.end(); ++itr)
	{
		cSound* obj = (*itr);
		
		if (obj->m_filename.compare(path) == 0)
		{
			return obj;
		}
	}
	
	
}
}
